package com.ider.deskcust;

import android.os.Parcel;
import android.os.Parcelable;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by ider-eric on 2016/5/23.
 * 此类实现了可序列化Parcelable接口
 */
public class Theme implements Parcelable {

    public String id;
    public String themename;
    public String themecode;
    public String themebg;
    public String themelogo;
    public String themetitle;
    public String themeaddtime;
    public String apptitlecolor;
    public String playlogo;
    public String result;

    public Theme() {
    }

    public Theme(JSONObject json) {
        try {
            id = json.getString("id");
            themename = json.getString("themename");
            themecode = json.getString("themecode");
            themebg = json.getString("themebg");
            themelogo = json.getString("themelogo");
            themetitle = json.getString("themetitle");
            themeaddtime = json.getString("themeaddtime");
            apptitlecolor = json.getString("apptitlecolor");
            playlogo = json.getString("playlogo");
            result = json.getString("result");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void writeToParcel(Parcel parcel, int flag) {

        parcel.writeString(id);
        parcel.writeString(themename);
        parcel.writeString(themecode);
        parcel.writeString(themebg);
        parcel.writeString(themelogo);
        parcel.writeString(themetitle);
        parcel.writeString(themeaddtime);
        parcel.writeString(apptitlecolor);
        parcel.writeString(playlogo);
        parcel.writeString(result);
    }


    public static final Creator<Theme> CREATOR = new Creator<Theme>() {
        @Override
        public Theme createFromParcel(Parcel parcel) {
            Theme entry = new Theme();
            entry.id = parcel.readString();
            entry.themename = parcel.readString();
            entry.themecode = parcel.readString();
            entry.themebg = parcel.readString();
            entry.themelogo = parcel.readString();
            entry.themetitle = parcel.readString();
            entry.themeaddtime = parcel.readString();
            entry.apptitlecolor = parcel.readString();
            entry.playlogo = parcel.readString();
            entry.result = parcel.readString();
            return entry;
        }

        @Override
        public Theme[] newArray(int i) {
            return new Theme[i];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }
}
